// =================================================================================================
//
//	CopyEngine Framework
//	Copyright 2012 Eran. All Rights Reserved.
//
//	This program is free software. You can redistribute and/or modify it
//	in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================

package gui.utils.blockEditor.ext
{
    import com.bit101.components.ComboBox;

    import flash.text.TextField;

    import gui.utils.GUIUtils;

    public class ExtSkillShopEditPanel extends ExtEditPanelBasic
    {
        private var mPriceNumTF:TextField;
        private var mAddValueNumTF:TextField;
        private var mShopLevelNumTF:TextField;

        private var mShopTypeSelector:ComboBox;

        public function ExtSkillShopEditPanel()
        {
        }

        //=================================//
        //=== Initialize & Dispose ========//
        //=================================//

        override protected function doInitialize():void
        {
            mPriceNumTF = mPanelMc["priceNumTF"];
            mAddValueNumTF = mPanelMc["addValueNumTF"];
            mShopLevelNumTF = mPanelMc["shopLevelNumTF"];

            mShopTypeSelector = new ComboBox(null, 0, 0, "ATK", ["ATK", "DEF"]);
            GUIUtils.replaceTargetWithPH(mShopTypeSelector, mPanelMc["shopTypeSelector"]);
        }

        //=================================//
        //====== Override Function ========//
        //=================================//

        override public function isShowPanel(_blockTypeStr:String):Boolean
        {
            return  _blockTypeStr == "SkillShop";
        }


        override protected function doSaveDataBackToVo():void
        {
            mTargetVo.priceArray = mPriceNumTF.text.split(",");
            mTargetVo.addAttributeNumArray = mAddValueNumTF.text.split(",");

            if (mShopTypeSelector.selectedItem == "ATK")
            {
                mTargetVo.attributeType = MapEditorConfig.ATTRIBUTE_TYPE_ATK;
            }
            else if (mShopTypeSelector.selectedItem == "DEF")
            {
                mTargetVo.attributeType = MapEditorConfig.ATTRIBUTE_TYPE_DEF;
            }
        }
    }
}
